<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="icon" type="image/png" sizes="144x144" href="./img/aico.png"/>
    <title>吃与不吃 不该选择</title>
</head>
<style>
    /* *{
        margin: 0;
        padding: 0;
    } */
/* body{
    background-color: rgb(246,246,246);
} */
#head{
    /* background-color: rgb(0, 132, 255); */
    margin: 0;
    background-color: white;
    text-align: center;
    font-size: 30px;
    color: rgb(51,51,51);
    /* color: rgb(0, 132, 255);; */
    position: fixed;
    display: inline-block;
    top: 0;
    left: 0;
    height: 50px;
    /* width: 100vw; */

    border-bottom-style: solid;
    /* border-bottom: 3px; */
    position: absolute;
    bottom: 1px;
    right: 0px;
    z-index: 10;
    /* text-shadow: 1px 1px #000; */
}
.button1{
    position: absolute;
    margin: 0 auto;
    width: 80vw;
    margin-left: 6px;
    margin-bottom: 20px;
    border: rgb(51,51,51);
    border-width: 1px;
    border-style: solid;
    padding: 3px;
    text-align: center;
    bottom: 2px;
    
}
#show{
    /* position: absolute; */
    /* top: 30vh; */
    width: 90vw;

    /* text-align: left; */
    /* margin: 0 auto; */
}
ul{
    margin-top: 70px;
}
ul>li>span{
    text-align: right;
}

.button{
    border: rgb(51,51,51);
    border-width: 1px;
    border-style: solid;
    padding: 1px;
    margin: 4px;
}
.dishname{
    margin: 7px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: rgb(51,51,51);
}
</style>
<script>
    foods = [
            "麻婆豆腐",
            "辣子鸡丁",
            "东坡肘子",
            "豆瓣鲫鱼",
            "口袋豆腐",
            "酸菜鱼",
            "夫妻肺片",
            "蚂蚁上树",
            "叫化鸡",
            "茄汁鱼卷",
            "鱼香肉丝",
            "干煸冬笋",
            "魔芋烧鸭",
            "锅贴鱼片",
            "麻辣肉丁",
            "鱼香茄饼",
            "冬菜肉末",
            "粉蒸鸡",
            "咸菜焖猪肉",
            "酿茄子",
            "酿豆腐",
            "梅菜扣肉",
            "客家盐焗鸡",
            "红糟排骨",
            "清风送爽",
            "炊太极虾",
            "广式烧填鸭",
            "池塘莲花",
            "佛跳墙",
            "醉排骨",
            "荔枝肉",
            "扳指干贝",
            "尤溪卜鸭",
            "七星鱼丸汤",
            "软溜珠廉鱼",
            "龙身凤尾虾",
            "清炖全鸡",
            "油爆双脆",
            "香露全鸡",
            "醉蚌肉",
            "烤方",
            "水晶肴蹄",
            "清炖蟹粉狮子头",
            "金陵丸子",
            "白汁圆菜",
            "黄泥煨鸡",
            "清炖鸡孚",
            "金陵板鸭",
            "金香饼",
            "鸡汤煮干丝",
            "肉酿生麸",
            "凤尾虾",
            "三套鸭",
            "无锡肉骨头",
            "陆稿荐酱猪头肉",
            "沛县狗肉",
            "西湖醋鱼",
            "东坡肉",
            "赛蟹羹",
            "家乡南肉",
            "干炸响铃",
            "荷叶粉蒸肉",
            "西湖莼菜汤",
            "龙井虾仁",
            "杭州煨鸡",
            "虎跑素火煺",
            "干菜焖肉",
            "蛤蜊黄鱼羹",
            "叫化童鸡",
            "香酥焖肉",
            "丝瓜卤蒸黄鱼",
            "三丝拌蛏",
            "油焖春笋",
            "虾爆鳝背",
            "海参盆蒸",
            "腊味合蒸",
            "走油豆鼓扣肉",
            "麻辣子鸡",
            "洞庭金龟",
            "网油叉烧洞庭桂鱼",
            "蝴蝶飘海",
            "冰糖湘莲",
            "红烧寒菌",
            "板栗烧菜心",
            "湘西酸肉",
            "炒血鸭",
            "清炖马蹄鳖",
            "黄山炖鸽",
            "腌鲜鳜鱼",
            "红烧果子狸",
            "毛豆腐",
            "桃脂烧肉",
            "清香炒悟鸡",
            "生熏仔鸡",
            "八大锤",
            "毛峰熏鲥鱼",
            "火烘鱼",
            "蟹黄虾盅",
            "奶汁肥王鱼",
            "香炸琵琶虾",
            "鱼咬羊",
            "香菇盒",
            ],
    shown = 1;
    num = foods.length;

    function t8id(id){
        var cursor = Math.floor((Math.random()*num)+1);
        var tampstr = foods[cursor-1]
        var rawlen = tampstr.length;
        if (rawlen < 7){
            for (var a=0;a<(7-rawlen);a++){
                tampstr= tampstr+ "&#12288;";
            }
        }
        // console.log(foods[cursor-1].length)
        document.getElementById(id).innerHTML = tampstr;
    }
    
    function d8id(id){
        document.getElementById(id).innerHTML = "";
    }

    function add(){
        if (shown==8){
            alert ("吃这些够了,不能再加了");
            return;
        }
        shown+=1;
        document.getElementById("l"+String(shown)).setAttribute("style", "");
        t8id("a"+String(shown));
    }

    function ed(){
        
        var flag = document.getElementById("edu").getAttribute("contenteditable");
        console.log(flag);
        if (flag=='true'){
            alert("关闭编辑模式");
            document.getElementById("edu").setAttribute('contenteditable', "false");
        } else {
            alert("启动编辑模式");
            document.getElementById("edu").setAttribute('contenteditable', "true");
        }
        
    }


    function addclicked(){
        var btn=document.querySelector(".button1");

        var timer=null;

        var touchstartHander=function(event){
            // event.preventDefault();
            // timer=setTimeout(LongPress,500);
            timer=setTimeout(ed,500);
        }

        var touchmoveHander=function(event){
            event.preventDefault();
            clearTimeout(timer);
            timer=null;
        }

        var touchendHander=function(event){
            event.preventDefault();
            // console.log("dianji")
            add();
            clearTimeout(timer);
            return false;
        }
        // 移动端
        btn.addEventListener("touchstart",touchstartHander,false);
        btn.addEventListener("touchmove",touchmoveHander,false);
        btn.addEventListener("touchend",touchendHander,false);
    }
    
</script>
<body>
    <div id="show">
        <ul id="edu">
            <li id="l1"><span id = "a1" class="dishname" style="float: left;">猪头肉&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> <span class="button" style="float: right" onclick="javascrtpt:d8id('a1')">清空</span><span class="button" style="float:right" onclick="javascrtpt:t8id('a1')">换一个</span> </li><br>
            <li id="l2" style="display: none;"><span id = "a2" class="dishname" style="float: left;"></span> <span class="button" style="float: right" onclick="javascrtpt:d8id('a2')">清空</span><span class="button" style="float:right" onclick="javascrtpt:t8id('a2')">换一个</span> </li><br>
            <li id="l3" style="display: none;"><span id = "a3" class="dishname" style="float: left;"></span> <span class="button" style="float: right" onclick="javascrtpt:d8id('a3')">清空</span><span class="button" style="float:right" onclick="javascrtpt:t8id('a3')">换一个</span> </li><br>
            <li id="l4" style="display: none;"><span id = "a4" class="dishname" style="float: left;"></span> <span class="button" style="float: right" onclick="javascrtpt:d8id('a4')">清空</span><span class="button" style="float:right" onclick="javascrtpt:t8id('a4')">换一个</span> </li><br>
            <li id="l5" style="display: none;"><span id = "a5" class="dishname" style="float: left;"></span> <span class="button" style="float: right" onclick="javascrtpt:d8id('a5')">清空</span><span class="button" style="float:right" onclick="javascrtpt:t8id('a5')">换一个</span> </li><br>
            <li id="l6" style="display: none;"><span id = "a6" class="dishname" style="float: left;"></span> <span class="button" style="float: right" onclick="javascrtpt:d8id('a6')">清空</span><span class="button" style="float:right" onclick="javascrtpt:t8id('a6')">换一个</span> </li><br>
            <li id="l7" style="display: none;"><span id = "a7" class="dishname" style="float: left;"></span> <span class="button" style="float: right" onclick="javascrtpt:d8id('a7')">清空</span><span class="button" style="float:right" onclick="javascrtpt:t8id('a7')">换一个</span> </li><br>
            <li id="l8" style="display: none;"><span id = "a8" class="dishname" style="float: left;"></span> <span class="button" style="float: right" onclick="javascrtpt:d8id('a8')">清空</span><span class="button" style="float:right" onclick="javascrtpt:t8id('a8')">换一个</span> </li><br>

        </ul>
    </div>
    <div class="button1" onclick="javascript:addclicked()">
        加一道菜
    </div>
    <div id="head" onclick="javascrtpt:window.location.href='./index.html' ">
        下一顿吃什么
    </div>
    <script>
        addclicked();
    </script>
</body>
</html>